env.setErrorMessageBoxEnabled(true) -- for debug

local function getMissleTGT()
  -- new function


  local tgt = SET_UNIT:New():FilterCoalitions("red"):FilterCategories("ground"):FilterActive():FilterStart()
  if tgt:GetFirst() ~= nil then
    --    MESSAGE:New("开始执行!", 10, "DEBUG", true):ToAll()
    local temp_unit = tgt:GetRandom()
    local temp_unit_coord = temp_unit:GetCoordinate()
    --    MESSAGE:New("temp_unit: " .. tostring(temp_unit), 10, "DEBUG", true):ToAll()
    --    MESSAGE:New("temp_unit.name: " .. tostring(temp_unit:GetName()), 10, "DEBUG", true):ToAll()
    --    MESSAGE:New("temp_unit.x: " .. tostring(temp_unit_coord:GetVec2().x), 10, "DEBUG", true):ToAll()
    --    MESSAGE:New("temp_unit.y: " .. tostring(temp_unit_coord:GetVec2().y), 10, "DEBUG", true):ToAll()
    --    MESSAGE:New("temp_unit.: " .. temp_unit_coord:ToStringLLDMS(), 10, "DEBUG", true):ToAll()

    local target = {}
    target.x = temp_unit_coord:GetVec2().x
    target.y = temp_unit_coord:GetVec2().y
    target.radius = 10
    target.expendQty = 1
    target.expendQtyEnabled = true
    local fire = { id = "FireAtPoint", params = target }
    Group.getByName("GRIFFIN CC #001"):getController():pushTask(fire)

    MESSAGE:New("战斧巡航导弹已投送", 10, "格里芬指挥部", true):ToAll()
    local tempsound = USERSOUND:New("ECHO回放321.ogg"):ToAll()
    trigger.action.outSound("ECHO回放完毕.ogg", 6)
  else
    MESSAGE:New("未找到目标", 10, "格里芬指挥部", true):ToAll()
  end
end

GRIFFIN_TACTICAL_DROP_MENU = missionCommands.addSubMenu("格里芬战术投放控制")
local ship_missle = missionCommands.addCommand("请求战斧巡航导弹", GRIFFIN_TACTICAL_DROP_MENU, getMissleTGT, nil)

_SETTINGS:SetPlayerMenuOff()
env.setErrorMessageBoxEnabled(false)
